package com.borko.healthcare.tapestry.pages;

import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.springframework.context.ApplicationContext;

import com.borko.healthcare.entities.interfaces.Medicine;
import com.borko.healthcare.persistence.hibernate.services.MedicineManager;
import com.borko.healthcare.persistence.hibernate.services.OrderManager;

public class DisplayOrder {
	
	private int medicineId;

	@Inject
	private ApplicationContext applicationContext;
	
	private MedicineManager medicineManager;
	private OrderManager orderManager;
	
	@Property
	@Persist
	private int qty;
	
	@Property
	private double price;
	
	public Medicine getMedicine() {
		medicineManager = (MedicineManager) applicationContext.getBean("medicineManager");
		return medicineManager.getMedicine(getMedicineId());
	}
	
	public void onActivate(int medicineId) {
		this.medicineId = medicineId;
	}
	
	public int onPassivate() {
		return this.medicineId;
	}

	public int getMedicineId() {
		return medicineId;
	}

	public void setMedicineId(int medicineId) {
		this.medicineId = medicineId;
	}

}
